#!/bin/bash
time if [ -d $1 ]
then
echo "found directory at the given path.. please delete before creating a new project"
else
echo "-----------------------------------------------"
echo "Creating project "$1
mkdir $1
cd $1
echo "Initializing symfony"
symfony -q generate:project $1
symfony -q generate:app rhCodeSetManager
echo "Configuring default settings"
cp ../sfConfigs/settings.yml apps/rhCodeSetManager/config/
cp ../sfConfigs/databases.yml config/
sed -i 's/Doctrine/Propel/' config/ProjectConfiguration.class.php
cd plugins
#svn co http://svn.symfony-project.com/plugins/sfDoctrinePlugin/branches/1.1/ sfDoctrinePlugin
echo 'Checking out RADHealth Plugins'
svn co -q https://radhealth.googlecode.com/svn/trunk/plugins/rhRimDataModelPlugin rhRimDataModelPlugin
#svn co -q https://radhealth.googlecode.com/svn/trunk/plugins/rhCodeSetManagerPlugin rhCodeSetManagerPlugin
cd ..
rm -r test
echo "Checking out test suite"
#svn co -q https://radhealth.googlecode.com/svn/trunk/plugins/rhSuiteTests test
symfony -q doctrine:build-all-reload --no-confirmation
symfony -q cc
echo 'Dropping bad foreign keys generated by the versionable behavior'
mysql -u testuser radhealth_test < ../sfConfigs/dropFK.sql
echo "Building entity test app and modules"
symfony -q generate:app entity
symfony -q doctrine:generate-module --with-show --non-verbose-templates entity entity Entity
symfony -q doctrine:generate-module --with-show --non-verbose-templates entity entityId EntityId
symfony -q doctrine:generate-module --with-show --non-verbose-templates entity entityGroup EntityGroup
symfony -q doctrine:generate-module --with-show --non-verbose-templates entity material Material
symfony -q doctrine:generate-module --with-show --non-verbose-templates entity manufacturedMaterial ManufacturedMaterial
symfony -q doctrine:generate-module --with-show --non-verbose-templates entity nonPersonLivingSubject NonPersonLivingSubject
symfony -q doctrine:generate-module --with-show --non-verbose-templates entity organization Organization
symfony -q doctrine:generate-module --with-show --non-verbose-templates entity organizationName OrganizationName
symfony -q doctrine:generate-module --with-show --non-verbose-templates entity person Person
symfony -q doctrine:generate-module --with-show --non-verbose-templates entity personName PersonName
symfony -q doctrine:generate-module --with-show --non-verbose-templates entity place Place
symfony -q generate:app locator
symfony -q doctrine:generate-module --with-show --non-verbose-templates locator entityLocatorParticipation EntityLocatorParticipation
symfony -q doctrine:generate-module --with-show --non-verbose-templates locator physicalLocator PhysicalLocator
symfony -q doctrine:generate-module --with-show --non-verbose-templates locator postalLocator PostalLocator
symfony -q doctrine:generate-module --with-show --non-verbose-templates locator teleLocator TeleLocator
symfony -q doctrine:generate-module --with-show --non-verbose-templates locator locator Locator



echo "-----------------------------------------"
fi

